package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.dto.TeachplanDto;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :chenjie
 * @date :Created 2023/2/4 22:18
 */
@Api("课程计划管理")
@RestController
public class TeachplanController {
    @Autowired
    TeachplanService teachplanService;

    @ApiParam("查询课程")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachplanDto> getTreeNodes(@PathVariable("courseId") Long courseId){
        return teachplanService.getTreeNodes(courseId);
    }

    @ApiParam("新增课程计划")
    @PostMapping("teachplan")
    public void saveTeachplan(@RequestBody SaveTeachplanDto dto){
        teachplanService.saveTeachplan(dto);
    }

    @ApiParam("删除小节")
    @DeleteMapping("teachplan/{id}")
    public void removeTeachplanByid(@PathVariable Long id){
        teachplanService.removeTeachplanByid(id);
    }
    @ApiParam("上移")
    @PostMapping("/teachplan/moveup/{id}")
    public void moveupByid(@PathVariable Long id){
        teachplanService.moveupByid(id);
    }
    @ApiParam("下移")
    @PostMapping("/teachplan/movedown/{id}")
    public void movedownByid(@PathVariable Long id){
        teachplanService.movedownByid(id);
    }

}
